﻿using Futajma.MigrationStudio.GenericImporter;
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Text;

namespace Futajma.MigrationStudio.GenericImporter
{
    public class ImporterLoader
    {
        public static IImporter GetImporter()
        {
            var libName = ConfigurationManager.AppSettings["ImportLoaderDLL"];

            Type importerType = Type.GetType(libName);
            IImporter importer = (IImporter)Activator.CreateInstance(importerType);
            if (importer == null)
            {
                //return null;
                throw new Exception(string.Format("Importer Loader cannot find the defined importert type [{0}]", libName));
            }
            else
            {
                return importer;
            }
        }
                       
        

        //    var assembly = Assembly.LoadFrom("selected_math_library.dll");
        //var types = assembly.GetTypes();

        //var mathType = (from type in types
        //                      where type.GetInterface("IMath") != null && !type.IsAbstract
        //                      select type).ToList();

        //if (mathType.Count > 0)
        //{
        //    IMath math = (IMath)Activator.CreateInstance(mathType);
        //    // call methods from math

        //}
    }
}